import win32print


def update_paper_size(cls, printer_id_current):  # 更新软件基本设置中的打印机ID
    cls.update_data('sys_setting', {"printer_id": printer_id_current.value})
    return


def set_input_text(input_box, value):  # 设置INPUTBOX中的值
    input_box.value = value
    return

def get_paper_size():
    # 获取默认打印机名称
    default_printer = win32print.GetDefaultPrinter()
    try:
        # 打开打印机句柄
        printer_handle = win32print.OpenPrinter(default_printer)
        # 获取打印机信息
        printer_info = win32print.GetPrinter(printer_handle, 2)
        # 获取默认纸张ID
        default_paper_id = printer_info['pDevMode'].PaperSize
        return default_paper_id
    except:
        # 关闭打印机句柄
        return 0